home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 May / CMCD0504.ISO / Software / Freeware / Programare / gdiplusdelphi / demos / Using Images, Bitmaps, and Metafiles / Reading and Writing Metadata / test / Unit1.pas < prev   
Encoding:
Pascal/Delphi Source File  |  2002-02-15  |  1.6 KB  |  65 lines

  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  7.   Dialogs, GDIPAPI, GDIPOBJ, StdCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Read: TButton;
  12.     Memo1: TMemo;
  13.     procedure ReadClick(Sender: TObject);
  14.   private
  15.     { Private declarations }
  16.   public
  17.     { Public declarations }
  18.   end;
  19.  
  20. var
  21.   Form1: TForm1;
  22.  
  23. implementation
  24.  
  25. {$R *.dfm}
  26.  
  27. procedure TForm1.ReadClick(Sender: TObject);
  28. var
  29.   Image: TGPImage;
  30.   size: UINT;
  31.   propertyItem: PPropertyItem;
  32.   x: array[0..31] of byte;
  33.   i:integer;
  34.   Str: String;
  35. type
  36.   ac= array of byte;
  37. begin
  38.   Image:= TGPImage.Create('..\untitled.JPG');
  39.  
  40.   // Assume that the image has a property item of type PropertyItemEquipMake.
  41.   // Get the size of that property item.
  42.   size := image.GetPropertyItemSize(PropertyTagImageTitle);
  43.  
  44.   // Allocate a buffer to receive the property item.
  45.   //propertyItem = (PropertyItem*)malloc(size);
  46.   GetMem(propertyItem ,Size);
  47.  
  48.   // Get the property item.
  49.   image.GetPropertyItem(PropertyTagImageTitle, size, propertyItem);
  50.  
  51.   // Display the members of the retrieved PropertyItem object.
  52.   memo1.Lines.Add(format('The length of the property item is %u.', [propertyItem.length]));
  53.   memo1.Lines.Add(format('The data type of the property item is %u.', [propertyItem.type_]));
  54.   for i := 0 to 31 do x[i] := ac(propertyItem)[i];
  55.   if(propertyItem.type_ = PropertyTagTypeASCII) then
  56.   begin
  57.     Str := PChar(propertyItem.value);
  58.     memo1.Lines.Add(format('The value of the property item is %s.', [str]));
  59.   end;
  60.    freemem(propertyItem);
  61.    image.Free;
  62. end;
  63.  
  64. end.
  65.